﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Views_viewhistory : System.Web.UI.UserControl
{
    OrderBus orbus;
    productBus prbus;
    protected void Page_Load(object sender, EventArgs e)
    {
        orbus = new OrderBus();
        prbus = new productBus();
        Data();
    }
    public void Data()
    {
        DataTable tabledefault = tableDefault();
        int id =Convert.ToInt32(Request.QueryString["idp"]);
        DataTable dt = orbus.getOrderProductByOrder_id(id);
        DataRow dr;
        foreach (DataRow r in dt.Rows)
        {
            DataTable dtal = prbus.getProductByID(Convert.ToInt32(r["product_id"]));
            dr = tabledefault.NewRow();
            dr["product_name"] = dtal.Rows[0]["product_name"].ToString();
            dr["image"] = "~//images//"+dtal.Rows[0]["image"].ToString() ;
            dr["quantity"] = r["quantity"];
            dr["price"] = r["price"];
            dr["total"] = r["OP_Total"];
            tabledefault.Rows.Add(dr);
        }
        productHistory.DataSource = tabledefault;
        productHistory.DataBind();
    }
    public DataTable tableDefault()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("product_name");
        dt.Columns.Add("image");
        dt.Columns.Add("quantity");
        dt.Columns.Add("price");
        dt.Columns.Add("total");
        return dt;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Default.aspx?action=cartHistory");
    }
}